<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加</title>
    <#assign base=request.contextPath  />
    <base id="base" href="${base}">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, adminUser-scalable=0">
    <link rel="stylesheet" href="${base}/static/win10/component/layui/css/layui.css" media="all">
    <script>
        var base =  "${base}";
    </script>
</head>
<body>
<br>
<form class="layui-form " action="">
          <div class="layui-form-item">
              <label class="layui-form-label"> (0在库/1调出/2已报废/3借出(校外))其他所属人id</label>
              <div class="layui-input-block">
                  <input type="text" id="userId" name="userId"   autocomplete="off" placeholder="请输入 (0在库/1调出/2已报废/3借出(校外))其他所属人id"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">1航材 / 2耗材</label>
              <div class="layui-input-block">
                  <input type="text" id="goodsType" name="goodsType"   autocomplete="off" placeholder="请输入1航材 / 2耗材"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">物品名称</label>
              <div class="layui-input-block">
                  <input type="text" id="goodsName" name="goodsName"   autocomplete="off" placeholder="请输入物品名称"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">计量单位</label>
              <div class="layui-input-block">
                  <input type="text" id="company" name="company"   autocomplete="off" placeholder="请输入计量单位"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">耗材在库数量 /(航材数量为1) </label>
              <div class="layui-input-block">
                  <input type="text" id="number" name="number"   autocomplete="off" placeholder="请输入耗材在库数量 /(航材数量为1) "
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">规格型号</label>
              <div class="layui-input-block">
                  <input type="text" id="model" name="model"   autocomplete="off" placeholder="请输入规格型号"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">单价</label>
              <div class="layui-input-block">
                  <input type="text" id="price" name="price"   autocomplete="off" placeholder="请输入单价"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">增加原因</label>
              <div class="layui-input-block">
                  <input type="text" id="reason" name="reason"   autocomplete="off" placeholder="请输入增加原因"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">备注</label>
              <div class="layui-input-block">
                  <input type="text" id="remarks" name="remarks"   autocomplete="off" placeholder="请输入备注"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">实体图片 </label>
              <div class="layui-input-block">
                  <input type="text" id="entityImgUrl" name="entityImgUrl"   autocomplete="off" placeholder="请输入实体图片 "
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">相关凭证</label>
              <div class="layui-input-block">
                  <input type="text" id="voucherImgUrl" name="voucherImgUrl"   autocomplete="off" placeholder="请输入相关凭证"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">相关凭证名称</label>
              <div class="layui-input-block">
                  <input type="text" id="voucherImgName" name="voucherImgName"   autocomplete="off" placeholder="请输入相关凭证名称"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">实体图片名称</label>
              <div class="layui-input-block">
                  <input type="text" id="entityImgName" name="entityImgName"   autocomplete="off" placeholder="请输入实体图片名称"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">日期单号（关联 date_no_id）</label>
              <div class="layui-input-block">
                  <input type="text" id="dateNoId" name="dateNoId"   autocomplete="off" placeholder="请输入日期单号（关联 date_no_id）"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">修改时间</label>
              <div class="layui-input-block">
                  <input type="text" id="updateTime" name="updateTime"   autocomplete="off" placeholder="请输入修改时间"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">创建时间</label>
              <div class="layui-input-block">
                  <input type="text" id="createTime" name="createTime"   autocomplete="off" placeholder="请输入创建时间"
                         class="layui-input">
              </div>
          </div>

    <div align="center">
        <button type="button" class="layui-btn" id="submit">保存</button>
    </div>
</form>

<script src="${base}/static/win10/component/layui/layui.js?t=1"></script>
<script src="${base}/static/win10/js/jquery-1.8.3.min.js?t=1"></script>
<script>
    layui.use(['form', 'layer'], function() {
        var form = layui.form
                , layer = layui.layer;
        $("#submit").on("click",function () {
            if(check()===false){
                return;
            }

            var formDate = {
                         userId:$("#userId").val(),
                         goodsType:$("#goodsType").val(),
                         goodsName:$("#goodsName").val(),
                         company:$("#company").val(),
                         number:$("#number").val(),
                         model:$("#model").val(),
                         price:$("#price").val(),
                         reason:$("#reason").val(),
                         remarks:$("#remarks").val(),
                         entityImgUrl:$("#entityImgUrl").val(),
                         voucherImgUrl:$("#voucherImgUrl").val(),
                         voucherImgName:$("#voucherImgName").val(),
                         entityImgName:$("#entityImgName").val(),
                         dateNoId:$("#dateNoId").val(),
                         updateTime:$("#updateTime").val(),
                           createTime:$("#createTime").val()
            }
            $.ajax({
                type: "POST",
                url: base+"/api/goods/admin/addGoods",
                data: formDate,
                success: function (data) {
                    layer.msg(data.message)
                    if (data.code === 200) {
                        window.location.href=base+"/api/goods/admin/main.html"
                    } else {

                    }
                }
            });
        })







        function check(){
                   if($("#userId").val().length<1){
                       layer.msg("请输入 (0在库/1调出/2已报废/3借出(校外))其他所属人id");
                       return false;
                   }
                   if($("#goodsType").val().length<1){
                       layer.msg("请输入1航材 / 2耗材");
                       return false;
                   }
                   if($("#goodsName").val().length<1){
                       layer.msg("请输入物品名称");
                       return false;
                   }
                   if($("#company").val().length<1){
                       layer.msg("请输入计量单位");
                       return false;
                   }
                   if($("#number").val().length<1){
                       layer.msg("请输入耗材在库数量 /(航材数量为1) ");
                       return false;
                   }
                   if($("#model").val().length<1){
                       layer.msg("请输入规格型号");
                       return false;
                   }
                   if($("#price").val().length<1){
                       layer.msg("请输入单价");
                       return false;
                   }
                   if($("#reason").val().length<1){
                       layer.msg("请输入增加原因");
                       return false;
                   }
                   if($("#remarks").val().length<1){
                       layer.msg("请输入备注");
                       return false;
                   }
                   if($("#entityImgUrl").val().length<1){
                       layer.msg("请输入实体图片 ");
                       return false;
                   }
                   if($("#voucherImgUrl").val().length<1){
                       layer.msg("请输入相关凭证");
                       return false;
                   }
                   if($("#voucherImgName").val().length<1){
                       layer.msg("请输入相关凭证名称");
                       return false;
                   }
                   if($("#entityImgName").val().length<1){
                       layer.msg("请输入实体图片名称");
                       return false;
                   }
                   if($("#dateNoId").val().length<1){
                       layer.msg("请输入日期单号（关联 date_no_id）");
                       return false;
                   }
                   if($("#updateTime").val().length<1){
                       layer.msg("请输入修改时间");
                       return false;
                   }
                   if($("#createTime").val().length<1){
                       layer.msg("请输入创建时间");
                       return false;
                   }
        }
    });

</script>
</body>
</html>